#include<bits/stdc++.h>
using namespace std;
#define int long long
int T,a[200005],ans=0;
signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>T;
    while(T--){
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<i;j++){
                if(a[i]==a[j]) ans+=a[i];
            }
        }
        cout<<ans<<endl;
        ans=0;
        memset(a,0,sizeof(a));
    }
    return 0;
}
